class Solution {
    public String longestCommonPrefix(String[] strs) {
        String pre = "";
        for(int i=0; i<strs[0].length(); i++){
            char c = strs[0].charAt(i);
            for(int j=1; j<strs.length; j++){
                if(strs[j].length()-1<i || strs[j].charAt(i)!=c)return pre;
            }
            pre+=c;
        }
        return pre;
    }
}